package br.com.fotoxbh.geracao.old;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;

import javax.imageio.ImageIO;


public class TestConcat {

	public static void main(String[] args) throws IOException, Exception {
		  File file1 = new File("C:\\Users\\Pablo\\Dropbox\\Fotos Churrasco na Laje\\leiaute\\fundo_quadrados.jpg");

		  BufferedImage img1 = ImageIO.read(file1);
		  	

		  int widthImg1 = img1.getWidth();
		  int heightImg1 = img1.getHeight();


		  int widthFinal = 1772;//widthImg1 * 4;
		int finalHeight = 1181;//heightImg1 * 3;
		
		BufferedImage img = new BufferedImage (
		    widthFinal,   // Final image will have width and height as
		    finalHeight,  // addition of widths and heights of the images we already have
		    BufferedImage.TYPE_INT_RGB);
		  
		  for(int i = 0; i < 4; i++) {
			  for (int j = 0; j < 3; j++) {
				  boolean imageDrawn = img.createGraphics().drawImage(img1, i*widthImg1,  j*heightImg1, null); // 0, 0 are the x and y positions
				  if(!imageDrawn) System.out.println("Erro ao desenhar imagem");	  
			}
		  }
		  
		  // horizontally
		  File final_image = new File("C:\\Users\\Pablo\\Dropbox\\Fotos Churrasco na Laje\\leiaute\\fundo_quadrados-final.jpg");
		  
		  boolean final_Image_drawing = ImageIO.write(img, "jpeg", final_image);
		  
		  if(!final_Image_drawing) System.out.println("Problems drawing final image");
		  
		  System.out.println("Successfull");
		 }
}
